﻿<UserControl 
    x:Class="Sidvall.UI.Wpf.Controls.ProgressControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:vms="clr-namespace:Sidvall.UI.ViewModels;assembly=Sidvall.UI"
    xmlns:Converters="clr-namespace:Sidvall.UI.Wpf.Converters" 
    mc:Ignorable="d" 
    d:DesignHeight="280" d:DesignWidth="500">

    <UserControl.Resources>
        <Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </UserControl.Resources>
    
    <Grid d:DataContext="{d:DesignInstance IsDesignTimeCreatable=True, Type={x:Type vms:ProgressControlViewModel}}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <TextBox Text="{Binding MonitoredTaskItem.Description}" IsReadOnly="True" AcceptsReturn="True" AcceptsTab="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" />
            <StackPanel Grid.Row="1">
                <StackPanel Visibility="{Binding MonitoredTaskItem.ShowProgress, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
                    <ProgressBar Height="23" Value="{Binding MonitoredTaskItem.Progress}" Margin="0,5,0,0" />
                </StackPanel>
                <StackPanel Visibility="{Binding MonitoredTaskItem.ShowTime, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="60" />
                            <ColumnDefinition Width="80" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <Label Content="Time:" Padding="0,5,0,5" />
                        <TextBox Grid.Column="1" Text="{Binding MonitoredTaskItem.CompletedTimeText, Mode=OneWay}" IsReadOnly="True" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" />
                    </Grid>
                </StackPanel>
                <StackPanel Visibility="{Binding MonitoredTaskItem.ShowTimeLeft, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="60" />
                            <ColumnDefinition Width="80" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <Label Content="Time left:" Padding="0,5,0,5" />
                        <TextBox Grid.Column="1" Text="{Binding MonitoredTaskItem.TimeLeftText, Mode=OneWay}" IsReadOnly="True" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" />
                    </Grid>
                </StackPanel>
                <StackPanel Visibility="{Binding MonitoredTaskItem.ShowSpeed, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="60" />
                            <ColumnDefinition Width="80" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <Label Grid.Column="0" Content="Speed:" Padding="0,5,0,5" />
                        <TextBox Grid.Column="1" Text="{Binding MonitoredTaskItem.SpeedText, Mode=OneWay}" IsReadOnly="True" HorizontalContentAlignment="Right" />
                        <Label Grid.Column="2" Content="{Binding MonitoredTaskItem.SpeedUnit}" />
                    </Grid>
                </StackPanel>
                <StackPanel Visibility="{Binding MonitoredTaskItem.CanCancel, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
                    <CheckBox Margin="0,5,0,0" IsChecked="{Binding CloseWhenFinished}" HorizontalAlignment="Left" VerticalContentAlignment="Center">Close dialog when finished</CheckBox>
                </StackPanel>
                <StackPanel Grid.Row="2" Background="#FFF0F0F0">
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Name="ButtonPanel" Margin="0,8,8,8">
                        <Button MinWidth="70" Padding="15,3,15,3" IsDefault="True" IsCancel="True" Command="{Binding ActionCommand}" Content="{Binding ActionCaption}" />
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
